package grsu.epam.airline.service;

import grsu.epam.airline.DAO.IAirportDAO;
import grsu.epam.airline.DAO.IAirportInRouteDAO;
import grsu.epam.airline.DAOImpl.DAOFactory;
import grsu.epam.airline.constant.Constant;
import grsu.epam.airline.model.Airport;

import java.sql.SQLException;

public class AirportInRouteService {
	public void addAirportInRoute(int flightId, int airportId) {
		IAirportInRouteDAO airportInRouteDao = (IAirportInRouteDAO) DAOFactory
				.getInstance().getDAO(Constant.AirportInRouteDAO);
		try {
			airportInRouteDao.addAirportInRoute(flightId, airportId);
		} catch (SQLException e) {
			e.printStackTrace();
		} finally {
			DAOFactory.getInstance().closeConnection(
					airportInRouteDao.getConnection());
		}
	}
/*	public Airport getAirportById(int airportId) {
		IAirportDAO airportDao = (IAirportDAO) DAOFactory.getInstance().getDAO(
				Constant.AirportDAO);
		Airport airport = null;
		try {
			airport = (Airport) airportDao.getAirportById(airportId);
		} catch (SQLException e) {
			e.printStackTrace();
		} finally {
			DAOFactory.getInstance()
					.closeConnection(airportDao.getConnection());
		}
		return airport;
	}
*/
	public void deleteAirportInRoute(int airportInRouteId) {
		IAirportInRouteDAO airportInRouteDao = (IAirportInRouteDAO) DAOFactory
				.getInstance().getDAO(Constant.AirportInRouteDAO);
		try {
			airportInRouteDao.deleteAirportInRoute(airportInRouteId);
		} catch (SQLException e) {
			e.printStackTrace();
		} finally {
			DAOFactory.getInstance().closeConnection(
					airportInRouteDao.getConnection());
		}
	}
}
